import request from "../utils/request"

//获取文章列表
export const getArticlesAPI =(params)=>{
    return request({
        url:"/v1_0/mp/articles",
        params
    })
}

//删除文章
export const delArticlesByIdAPI=(id)=>{
    return request({
        url:`/v1_0/mp/articles/${id}`,
        method:'DELETE'
    })
}

//新增文章,存为草稿文章接口
export const addArticles=(data,draft=false)=>{
    return request({
        url:`/v1_0/mp/articles?draft=${draft}`,
        method:'post',
        data
    })
}

// 根据id获取文章详情
export const getArticlesByIdAPI=(id)=>{
    return request({
        url:`/v1_0/mp/articles/${id}`,
        method:'get'
    })
}

//修改文章接口
export const editArticles=(data,draft=false)=>{
    return request({
        url:`/v1_0/mp/articles/${data.id}?draft=${draft}`,
        method:'put',
        data
    })
}